package com.flower.salary.common.config;

import com.flower.salary.common.utils.R;
import com.flower.salary.common.utils.SalaryException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-03-01 17:14
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionAdvice {


    //处理http异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R Exception(Exception e){
        System.out.println(e);
        R ok = R.error(e.getMessage());
        return ok;
    }
}
